package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.reggie.entity.OrderDetail;
import com.itheima.reggie.mapper.OrderDetailMapper;
import com.itheima.reggie.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrderDetailServiceImpl implements OrderDetailService {

    @Autowired
    private OrderDetailMapper orderDetailMapper;
    /**
     * 添加订单详情对象
     *
     * @param orderDetail
     * @return
     */
    @Override
    public int add(OrderDetail orderDetail) {

        return orderDetailMapper.insert(orderDetail);
    }

    @Override
    public List<OrderDetail> list(Long id) {
        LambdaQueryWrapper<OrderDetail> wrapper =new LambdaQueryWrapper();
        wrapper.eq(OrderDetail::getOrderId,id);
        List<OrderDetail> orderDetails = orderDetailMapper.selectList(wrapper);
        return  orderDetails;
    }
}
